﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UFSControl
{
    public partial class EditChannel : Form
    {
        private KService vService;

        public EditChannel()
        {
            InitializeComponent();
        }

        public void SetData(KService aService)
        {
            vService = aService;
            NrTextBox.Text = aService.ChannelNo.ToString();
            NameTextBox.Text = aService.Name;
            FrequenzTextBox.Text =aService.Carrier.Frequency.ToString();
            EnableCheckBox.Checked = aService.Locked;
            SkipCheckBox.Checked = aService.Skipped;
            SidTextBox.Text =aService.Sid;
            TsidTextBox.Text = aService.Tsid;
            OidTextBox.Text = aService.Onid;
            VideoTextBox.Text = aService.Vpid;
            AudioTextBox.Text = aService.Apid;
            PcrTextBox.Text = aService.PCRpid; 
        }

        private void CancelButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                //Daten zurückschreiben
                vService.Name = NameTextBox.Text;
                vService.Carrier.Frequency = Convert.ToInt32(FrequenzTextBox.Text);
                vService.Locked = EnableCheckBox.Checked;
                vService.Skipped = SkipCheckBox.Checked;
                vService.Sid = SidTextBox.Text;
                vService.Tsid = TsidTextBox.Text;
                vService.Onid = OidTextBox.Text;
                vService.Vpid = VideoTextBox.Text;
                vService.Apid = AudioTextBox.Text;
                vService.PCRpid = PcrTextBox.Text;
                Close();
            }
            catch 
            {
                MessageBox.Show("eingegebene Daten sind nicht korrekt!");
            }
        }
    }
}
